package com.hsjk.szwj.module.pay.service;

import com.hsjk.szwj.module.pay.controller.app.order.vo.UnifiedOrderReqVO;
import com.hsjk.szwj.module.pay.dal.dataobject.config.AbstractResp;
import com.hsjk.szwj.module.pay.dal.dataobject.config.MchAppConfigContext;
import com.hsjk.szwj.module.pay.dal.dataobject.order.PayOrderDO;
import com.hsjk.szwj.module.pay.enums.IfCodeEnum;
import com.hsjk.szwj.module.pay.util.ChannelCertConfigKitBean;
import com.hsjk.szwj.module.pay.util.PaywayUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author chenjiawei
 * @desc 支付plus
 * @Date 2023/08/27 23:46
 **/
@Service
public class PlspayPaymentService extends AbstractPaymentService {
    @Resource
    protected ChannelCertConfigKitBean channelCertConfigKitBean;
    @Resource
    protected ConfigContextQueryService configContextQueryService;

    @Override
    public String getIfCode() {
        return IfCodeEnum.PLSPAY.getCode();
    }

    @Override
    public boolean isSupport(String wayCode) {
        return true;
    }

    @Override
    public String preCheck(UnifiedOrderReqVO bizRQ, PayOrderDO payOrder) {
        return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode())
                .preCheck(bizRQ, payOrder);
    }

    @Override
    public AbstractResp pay(UnifiedOrderReqVO bizRQ, PayOrderDO payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
        return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode())
                .pay(bizRQ, payOrder, mchAppConfigContext);
    }
}
